package com.lenovo.mso2o;

import android.test.ActivityInstrumentationTestCase2;

import com.robotium.solo.Solo;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;

/**
 * Created by hippo on 1/28/16.
 */


@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 23, manifest = "src/main/AndroidManifest.xml")
public class DeckardActivityTest extends ActivityInstrumentationTestCase2 {
    @SuppressWarnings("rawtypes")
        private Solo solo;

        private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.lenovo.mso2o.ui.LoginActivity";

        private static Class<?> launcherActivityClass;
        static{
            try {
                launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            }
        }

        @SuppressWarnings("unchecked")
        public DeckardActivityTest() throws ClassNotFoundException {
            super(launcherActivityClass);
        }

        public void setUp() throws Exception {
            super.setUp();
            solo = new Solo(getInstrumentation());
            getActivity();
        }

        @Override
        public void tearDown() throws Exception {
            solo.finishOpenedActivities();
            super.tearDown();
        }

    @Test
        public void testRun() {
            //Wait for activity: 'com.example.ExampleActivty'
            solo.waitForActivity("ExampleActivty", 2000);
            //Clear the EditText editText1
            solo.clearEditText((android.widget.EditText) solo.getView("editText1"));
            solo.enterText((android.widget.EditText) solo.getView("editText1"), "This is an example text");
        }
}
